package com.deruan.hotcore.resource.table.plugin;

import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JTable;
import javax.swing.SwingConstants;

import org.columba.mail.gui.table.model.MessageNode;
import org.columba.mail.gui.table.plugins.DefaultLabelRenderer;
import org.columba.mail.message.ColumbaHeader;
import org.columba.mail.resourceloader.MailImageLoader;
import org.columba.mail.util.MailResourceLoader;

public class ResourceFlaggedRenderer extends ResourceDefaultLabelRendrer
{
	boolean bool;
    ImageIcon image1;
    public ResourceFlaggedRenderer()
    {
    	super();
    	setHorizontalAlignment(SwingConstants.CENTER);
        image1 = MailImageLoader.getSmallIcon("flag.png");
    }
    
    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
                row, column);

            if (value == null) {
                setIcon(null);

                return this;
            }

            //boolean flagged = ((ColumbaHeader) ((MessageNode) value).getHeader()).getFlags().getFlagged();
            boolean flagged = true;
            if (flagged) {
                setIcon(image1);

                setToolTipText(MailResourceLoader.getString("header", "column",
                        "flagged"));
            } else {
                setIcon(null);
            }
            
            setText("");

            return this;
        }
}
